package Differ

var (
	Map *mapType
	Set *setType
)

func strKeyMapDifferA2BT1[T any](srcList map[string]T, dstList map[string]T, addList map[string]T, eqlList map[string]T) {
	strKeyMapClear(addList)
	strKeyMapClear(eqlList)

	for k, v := range dstList {
		_, ok := srcList[k]

		if !ok {
			addList[k] = v
		} else {
			eqlList[k] = v
		}

	}
}

func strKeySetDifferA2BT2[T1 any, T2 any](srcList map[string]T1, dstList map[string]T2, addList map[string]T2, eq1List map[string]T1, eq2List map[string]T2) {
	strKeySetClear(addList)

	for k, v := range dstList {
		_, ok := srcList[k]

		if !ok {
			addList[k] = v
			continue
		} else {
			eq1List[k] = srcList[k]
			eq2List[k] = dstList[k]
		}

		delete(addList, k)
	}
}

func strKeySetClear[T any](list map[string]T) {
	for k := range list {
		delete(list, k)
	}
}

func strKeyMapClear[T any](list map[string]T) {
	for k := range list {
		delete(list, k)
	}
}

func KStringVAny[T any](srcList map[string]T, dstList map[string]T, addList map[string]T, delList map[string]T, eqlList map[string]T) {
	strKeyMapDifferA2BT1(srcList, dstList, addList, eqlList)
	strKeyMapDifferA2BT1(dstList, srcList, delList, eqlList)
}
